import 'dart:math';

import 'package:flutter_soundmagus/model/XoverItemModel.dart';

// ignore: non_constant_identifier_names
class DrawFunction {
  // ignore: non_constant_identifier_names
  static double FREQUENCY_MAX = 20000.0;
  // ignore: non_constant_identifier_names
  static double FREQUENCY_MIN = 20.0;

  static double F = 48000.0; //EZDSP
//static double F = 96000.0;//BTDSP
  static double R = 6.283185307179586;

  static double log10(num x) => log(x) / ln10;

  //oct_type值定义:(BW-巴特沃斯，BS-贝塞尔,LK-宁克)
//0 BW-06 巴特沃斯6DB (BS-06 贝塞尔)
//1 BW-12 巴特沃斯12DB
//2 BW-18 巴特沃斯18DB
//3 BW-24 巴特沃斯24DB
//4 BW-36 巴特沃斯36DB
//5 BW-48 巴特沃斯48DB

//6 BS-12 贝塞尔12db
//7 BS-18 贝塞尔18db
//8 BS-24 贝塞尔24DB
//9 BS-36 贝塞尔36DB
//10 BS-48 贝塞尔48DB

//11 LK-12 宁克12db
//12 LK-24 宁克24db
//13 LK-36 宁克36DB
//14 LK-48 宁克48DB
  static int getOctType(XoverItemModel xover, bool isHPass) {
    XoverItemHighLowModel model = isHPass ? xover.high : xover.low;
    /**0Butter 1Bessel 2Link-Ril*/
    if (model.type == 0) {
      return model.slope;
      /**0:6 1:12 2:24 3:48*/
      /*switch (model.slope) {
            case 0:
                //6
                return 0;
            case 1:
                //12
                return 1;
            case 2:
                //24
                return 3;
            case 3:
                //48
                return 5;
        }*/
    } else if (model.type == 1) {
      switch (model.slope) {
        case 0:
          //6
          return 0;
        default:
          return (model.slope + 5);
      }
    } else if (model.type == 2) {
      switch (model.slope) {
        case 0:
          //6
          return 0;
        case 1:
          //12
          return 11;
        case 2:
          //24
          return 12;
        case 3:
          //36
          return 13;
        case 4:
          //48
          return 14;
      }
    }
    return -1;
  }

  static List<double> createArray(int count) {
    List<double> arr = List.generate(count, (i) => 0);
    return arr;
  }

  static void mk(double f, List<double> a, List<double> b, List<double> one,
      int length, bool ispol) {
    int len = length;
    double x, w, u, v, s, t, h;

    if (ispol) {
      for (int i = 0; i < len; i++) {
        x = pow(10,
            (i - 0) / (len - 0) * (log10(20000.0) - log10(20.0)) + log10(20.0)) as double;

        w = 2 * pi * x / 48000;

        u = (b[0] + b[1] * cos(w) + b[2] * cos(2 * w));
        v = (-b[1] * sin(w) - b[2] * sin(2 * w));
        s = (a[0] + a[1] * cos(w) + a[2] * cos(2 * w));
        t = (-a[1] * sin(w) - a[2] * sin(2 * w));

        // ignore: non_constant_identifier_names
        double Im = (s * v - t * u);
        // ignore: non_constant_identifier_names
        double Re = (s * u + t * v);

        h = 180 * atan2(Im, Re) / pi;

        one[i] = (h);
      }
    } else {
      for (int i = 0; i < len; i++) {
        x = pow(10,
            (i - 0) * (log10(20000.0) - log10(20.0)) / (len - 0) + log10(20.0)) as double;
        w = 2 * pi * x / 48000.0;

        u = (b[0] + b[1] * cos(w) + b[2] * cos(2 * w));
        v = (-b[1] * sin(w) - b[2] * sin(2 * w));
        s = (a[0] + a[1] * cos(w) + a[2] * cos(2 * w));
        t = (-a[1] * sin(w) - a[2] * sin(2 * w));

        h = sqrt((pow(u, 2) + pow(v, 2)) / (pow(s, 2) + pow(t, 2)));

        one[i] = (log10(h));
      }
    }
  }

  // ignore: non_constant_identifier_names
  static void cal_point_xover(
      // ignore: non_constant_identifier_names
      double f, int oct_type, bool ishpass, List<double> line_xover) {
    // ignore: non_constant_identifier_names
    int line_xover_length = line_xover.length;
    // ignore: unused_local_variable
    double pow10 = 10000000000;
    List<double> p = createArray(4);
    List<double> a0 = createArray(3);
    List<double> a1 = createArray(3);
    List<double> a2 = createArray(3);
    List<double> a3 = createArray(3);
    List<double> b0 = createArray(3);
    List<double> b1 = createArray(3);
    List<double> b2 = createArray(3);
    List<double> b3 = createArray(3);
    List<double> one_0 = [];
    List<double> one_1 = [];
    List<double> one_2 = [];
    List<double> one_3 = [];

    double w0 = 2 * pi * f / 48000;
    double oc = 2 * tan(w0 / 2);
    double c1 = oc * tan(w0 / 2);

    if (!ishpass) // 是不是高通
    {
      switch (oct_type) //
          {
        case 0: //BW-06
          {
            {
              a0[0] = 1;
              a0[1] = ((oc - 2) / (2 + oc));
              a0[2] = 0;
              b0[0] = (oc / (2 + oc));
              b0[1] = b0[0];
              b0[2] = 0;
              //                    one_0 = new double[line_xover_length];
              one_0 = createArray(line_xover_length);
              //                    mk(f, a0, b0,one_0,line_xover_length, false);
              mk(f, a0, b0, one_0, line_xover_length, false);
              for (int i = 0; i < line_xover_length; i++) {
                line_xover[i] = one_0[i];
              }

              if (f == FREQUENCY_MAX) {
                for (int i = 0; i < line_xover_length; i++) {
                  // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                  line_xover[i] = 0;
                }
              }
            }
          }
          break;
        case 1: // BW-12
          {
            {
              p[0] = 1.41421356237309;

              b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
              b0[1] = (2 * b0[0]);
              b0[2] = b0[0];
              a0[0] = 1;
              a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
              a0[2] = ((4 - 2 * p[0] * oc + oc * oc) /
                  (4 + 2 * p[0] * oc + oc * oc));
              //                    one_0 = new double[line_xover_length];
              one_0 = createArray(line_xover_length);
              //                    mk(f, a0, b0,  one_0,line_xover_length, false);
              mk(f, a0, b0, one_0, line_xover_length, false);

              for (int i = 0; i < line_xover_length; i++) {
                line_xover[i] = one_0[i];
              }

              if (f == FREQUENCY_MAX) {
                for (int i = 0; i < line_xover_length; i++) {
                  // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                  line_xover[i] = 0;
                }
              }
            }
          }
          break;
        case 2: //BW-18
          {
            p[0] = 1;
            p[1] = 1;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (p[1] * oc / (2 + p[1] * oc));
            b1[1] = b1[0];
            b1[2] = 0;
            a1[0] = 1;
            a1[1] = ((p[1] * oc - 2) / (2 + p[1] * oc));
            a1[2] = 0;

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);

            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = ((one_0[i] + one_1[i]));
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 3: //BW-24
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);

            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 4: //BW_36
          {
            p[0] = 0.51763809020504;
            p[1] = 1.41421356237309;
            p[2] = 1.93185165257814;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
            b2[1] = (2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
            a2[2] =
                ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);

            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 5: //BW-48
          {
            p[0] = 0.39018064403226;
            p[1] = 1.11114046603920;
            p[2] = 1.66293922460509;
            p[3] = 1.96157056080646;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
            b2[1] = (2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
            a2[2] =
                ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));

            b3[0] = (oc * oc / (4 + 2 * p[3] * oc + oc * oc));
            b3[1] = (2 * b3[0]);
            b3[2] = b3[0];
            a3[0] = 1;
            a3[1] = (2 * (oc * oc - 4) / (4 + 2 * p[3] * oc + oc * oc));
            a3[2] =
                ((4 - 2 * p[3] * oc + oc * oc) / (4 + 2 * p[3] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);
            //                mk(f, a3, b3,  one_3, line_xover_length, false);

            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);

            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i] + one_3[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 6: //BS-12
          {
            p[0] = 1.73205080756888;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = one_0[i];
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 7: //BS-18
          {
            p[0] = 1.49128077169616;
            p[1] = 0.94160002653321;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (p[1] * oc / (2 + p[1] * oc));
            b1[1] = b1[0];
            b1[2] = 0;
            a1[0] = 1;
            a1[1] = ((p[1] * oc - 2) / (2 + p[1] * oc));
            a1[2] = 0;

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
                //TRACE(_T("sdsfdfsd\r\n"));

              }
            }
          }
          break;
        case 8: //BS-24
          {
            p[0] = 1.31442234334377;
            p[1] = 1.80951759357649;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 9: //BS-36
          {
            p[0] = 1.81878136609445;
            p[1] = 1.59930837166566;
            p[2] = 1.07710536333862;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
            b2[1] = (2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
            a2[2] =
                ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);

            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }

          break;
        case 10: //BS-48
          {
            p[0] = 1.81936630933058;
            p[1] = 1.69465016047187;
            p[2] = 1.42227636169708;
            p[3] = 0.92434808250642;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
            b2[1] = (2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
            a2[2] =
                ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));

            b3[0] = (oc * oc / (4 + 2 * p[3] * oc + oc * oc));
            b3[1] = (2 * b3[0]);
            b3[2] = b3[0];
            a3[0] = 1;
            a3[1] = (2 * (oc * oc - 4) / (4 + 2 * p[3] * oc + oc * oc));
            a3[2] =
                ((4 - 2 * p[3] * oc + oc * oc) / (4 + 2 * p[3] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);
            //                mk(f, a3, b3,  one_3, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 11: //LK-12
          {
            b0[0] = (oc / (2 + oc));
            b0[1] = b0[0];
            b0[2] = 0;
            a0[0] = 1;
            a0[1] = ((oc - 2) / (2 + oc));
            a0[2] = 0;

            b1[0] = b0[0];
            b1[1] = b0[1];
            b1[2] = b0[2];
            a1[0] = a0[0];
            a1[1] = a0[1];
            a1[2] = a0[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 12: //LK-24
          {
            p[0] = 1.41421356237309;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = b0[0];
            b1[1] = b0[1];
            b1[2] = b0[2];
            a1[0] = a0[0];
            a1[1] = a0[1];
            a1[2] = a0[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 13: //LK-36
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;
            p[2] = 1.41421356237309;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (4 + 2 * p[2] * oc + oc * oc));
            b2[1] = (2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (2 * (oc * oc - 4) / (4 + 2 * p[2] * oc + oc * oc));
            a2[2] =
                ((4 - 2 * p[2] * oc + oc * oc) / (4 + 2 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 14: //LK-48
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;

            b0[0] = (oc * oc / (4 + 2 * p[0] * oc + oc * oc));
            b0[1] = (2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (2 * (oc * oc - 4) / (4 + 2 * p[0] * oc + oc * oc));
            a0[2] =
                ((4 - 2 * p[0] * oc + oc * oc) / (4 + 2 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (4 + 2 * p[1] * oc + oc * oc));
            b1[1] = (2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (2 * (oc * oc - 4) / (4 + 2 * p[1] * oc + oc * oc));
            a1[2] =
                ((4 - 2 * p[1] * oc + oc * oc) / (4 + 2 * p[1] * oc + oc * oc));

            b2[0] = b0[0];
            b2[1] = b0[1];
            b2[2] = b0[2];
            a2[0] = a0[0];
            a2[1] = a0[1];
            a2[2] = a0[2];

            b3[0] = b1[0];
            b3[1] = b1[1];
            b3[2] = b1[2];
            a3[0] = a1[0];
            a3[1] = a1[1];
            a3[2] = a1[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //
            //                mk(f, a0, b0,  one_0, line_xover_length, false);
            //                mk(f, a1, b1,  one_1, line_xover_length, false);
            //                mk(f, a2, b2,  one_2, line_xover_length, false);
            //                mk(f, a3, b3,  one_3, line_xover_length, false);

            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i] + one_3[i]);
            }

            if (f == FREQUENCY_MAX) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;

        default:
          break;
      }
    } else {
      switch (oct_type) {
        case 0: //BW-06
          {
            p[0] = 1;

            b0[0] = (oc / (c1 + p[0] * oc));
            b0[1] = (-b0[0]);
            b0[2] = 0;
            a0[0] = 1;
            a0[1] = (-(p[0] * oc - c1) / (c1 + p[0] * oc));
            a0[2] = 0;
            //                one_0 = new double[line_xover_length];
            //                mk(f, a0, b0, one_0,line_xover_length,false);
            one_0 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = one_0[i];
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 1: //BW-12
          {
            p[0] = 1.41421356237309;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            //                one_0 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = one_0[i];
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 2: //BW-18
          {
            p[0] = 1;
            p[1] = 1;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (p[1] * oc / (c1 + p[1] * oc));

            b1[1] = (-b1[0]);
            b1[2] = 0;
            a1[0] = 1;
            a1[1] = (-(p[1] * oc - c1) / (c1 + p[1] * oc));
            a1[2] = 0;

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0, one_0,line_xover_length ,false);
            //                mk(f, a1, b1, one_1,line_xover_length ,false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }
            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 3: //BW-24
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 4: //BW-36
          {
            p[0] = 0.51763809020504;
            p[1] = 1.41421356237309;
            p[2] = 1.93185165257814;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
            b2[1] = (-2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));
            a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            //                mk(f, a2, b2,one_2,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 5: //BW-48
          {
            p[0] = 0.39018064403226;
            p[1] = 1.11114046603920;
            p[2] = 1.66293922460509;
            p[3] = 1.96157056080646;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
            b2[1] = (-2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));
            a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));

            b3[0] = (oc * oc / (c1 * c1 + c1 * p[3] * oc + oc * oc));
            b3[1] = (-2 * b3[0]);
            b3[2] = b3[0];
            a3[0] = 1;
            a3[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[3] * oc + oc * oc));
            a3[2] = ((c1 * c1 - c1 * p[3] * oc + oc * oc) /
                (c1 * c1 + c1 * p[3] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            //                mk(f, a2, b2,one_2,line_xover_length, false);
            //                mk(f, a3, b3,one_3,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i] + one_3[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 6: //BS-12
          {
            p[0] = 1.73205080756888;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = one_0[i];
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 7: //BS-18
          {
            p[0] = 1.49128077169616;
            p[1] = 0.94160002653321;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (p[1] * oc / (c1 + p[1] * oc));
            b1[1] = (-b1[0]);
            b1[2] = 0;
            a1[0] = 1;
            a1[1] = (-(p[1] * oc - c1) / (c1 + p[1] * oc));
            a1[2] = 0;

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0, one_0,line_xover_length ,false);
            //                mk(f, a1, b1, one_1,line_xover_length ,false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = ((one_0[i] + one_1[i]));
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 8: //BS-24
          {
            p[0] = 1.31442234334377;
            p[1] = 1.80951759357649;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //
            //                mk(f, a0, b0, one_0,line_xover_length ,false);
            //                mk(f, a1, b1, one_1,line_xover_length ,false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;

        case 9: //BS-36
          {
            p[0] = 1.81878136609445;
            p[1] = 1.59930837166566;
            p[2] = 1.07710536333862;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
            b2[1] = (-2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));
            a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                mk(f, a0, b0, one_0,line_xover_length ,false);
            //                mk(f, a1, b1, one_1,line_xover_length ,false);
            //                mk(f, a2, b2, one_2,line_xover_length ,false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 10: //BS-48
          {
            p[0] = 1.81936630933058;
            p[1] = 1.69465016047187;
            p[2] = 1.42227636169708;
            p[3] = 0.92434808250642;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
            b2[1] = (-2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));
            a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));

            b3[0] = (oc * oc / (c1 * c1 + c1 * p[3] * oc + oc * oc));
            b3[1] = (-2 * b3[0]);
            b3[2] = b3[0];
            a3[0] = 1;
            a3[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[3] * oc + oc * oc));
            a3[2] = ((c1 * c1 - c1 * p[3] * oc + oc * oc) /
                (c1 * c1 + c1 * p[3] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //                mk(f, a0, b0, one_0,line_xover_length ,false);
            //                mk(f, a1, b1, one_1,line_xover_length ,false);
            //                mk(f, a2, b2, one_2,line_xover_length ,false);
            //                mk(f, a3, b3, one_3,line_xover_length ,false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = ((one_0[i] + one_1[i] + one_2[i] + one_3[i]));
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 11: //LK-12
          {
            b0[0] = (oc / (c1 + oc));
            b0[1] = (-b0[0]);
            b0[2] = 0;
            a0[0] = 1;
            a0[1] = (-(oc - c1) / (c1 + oc));
            a0[2] = 0;

            b1[0] = b0[0];
            b1[1] = b0[1];
            b1[2] = b0[2];
            a1[0] = a0[0];
            a1[1] = a0[1];
            a1[2] = a0[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 12: //LK-24
          {
            p[0] = 1.41421356237309;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = b0[0];
            b1[1] = b0[1];
            b1[2] = b0[2];
            a1[0] = a0[0];
            a1[1] = a0[1];
            a1[2] = a0[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 13: //LK-36
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;
            p[2] = 1.41421356237309;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = (oc * oc / (c1 * c1 + c1 * p[2] * oc + oc * oc));
            b2[1] = (-2 * b2[0]);
            b2[2] = b2[0];
            a2[0] = 1;
            a2[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));
            a2[2] = ((c1 * c1 - c1 * p[2] * oc + oc * oc) /
                (c1 * c1 + c1 * p[2] * oc + oc * oc));

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            //                mk(f, a2, b2,one_2,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;
        case 14: //LK-48
          {
            p[0] = 0.76536686473018;
            p[1] = 1.84775906502257;

            b0[0] = (oc * oc / (c1 * c1 + c1 * p[0] * oc + oc * oc));
            b0[1] = (-2 * b0[0]);
            b0[2] = b0[0];
            a0[0] = 1;
            a0[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));
            a0[2] = ((c1 * c1 - c1 * p[0] * oc + oc * oc) /
                (c1 * c1 + c1 * p[0] * oc + oc * oc));

            b1[0] = (oc * oc / (c1 * c1 + c1 * p[1] * oc + oc * oc));
            b1[1] = (-2 * b1[0]);
            b1[2] = b1[0];
            a1[0] = 1;
            a1[1] = (-2 *
                (oc * oc - c1 * c1) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));
            a1[2] = ((c1 * c1 - c1 * p[1] * oc + oc * oc) /
                (c1 * c1 + c1 * p[1] * oc + oc * oc));

            b2[0] = b0[0];
            b2[1] = b0[1];
            b2[2] = b0[2];
            a2[0] = a0[0];
            a2[1] = a0[1];
            a2[2] = a0[2];

            b3[0] = b1[0];
            b3[1] = b1[1];
            b3[2] = b1[2];
            a3[0] = a1[0];
            a3[1] = a1[1];
            a3[2] = a1[2];

            //                one_0 = new double[line_xover_length];
            //                one_1 = new double[line_xover_length];
            //                one_2 = new double[line_xover_length];
            //                one_3 = new double[line_xover_length];
            //                mk(f, a0, b0,one_0,line_xover_length, false);
            //                mk(f, a1, b1,one_1,line_xover_length, false);
            //                mk(f, a2, b2,one_2,line_xover_length, false);
            //                mk(f, a3, b3,one_3,line_xover_length, false);
            one_0 = createArray(line_xover_length);
            one_1 = createArray(line_xover_length);
            one_2 = createArray(line_xover_length);
            one_3 = createArray(line_xover_length);
            mk(f, a0, b0, one_0, line_xover_length, false);
            mk(f, a1, b1, one_1, line_xover_length, false);
            mk(f, a2, b2, one_2, line_xover_length, false);
            mk(f, a3, b3, one_3, line_xover_length, false);

            for (int i = 0; i < line_xover_length; i++) {
              line_xover[i] = (one_0[i] + one_1[i] + one_2[i] + one_3[i]);
            }

            if (f == FREQUENCY_MIN) {
              for (int i = 0; i < line_xover_length; i++) {
                // line_xover[i] =((line_xover[i] * pow10))/ pow10;
                line_xover[i] = 0;
              }
            }
          }
          break;

        default:
          break;
      }
    }

    //    delete  []p ;
    //    delete []a0 ;delete []b0;
    //    delete []a1,delete [] b1 ;
    //    delete []a2 ,delete [] b2 ;
    //    delete []a3 ,delete [] b3 ;

    //    if(one_0!=NULL)
    //        delete []one_0;
    //
    //    if(one_1!=NULL)
    //        delete []one_1;
    //    if(one_2!=NULL)
    //        delete []one_2;
    //    if(one_3!=NULL)
    //        delete []one_3;
  }
}
